package sample.business.util;


import com.google.common.collect.Maps;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.util.Map;

/**
 * Created by lilongfei on 2016/12/15.
 */
public class TestDriver {

    public static Map.Entry<String, String> test(String driver, String url, String name, String password){

        Connection connection = null;
        try{
            Class.forName(driver);
            connection = DriverManager.getConnection(url,name,password);
            return Maps.immutableEntry("1","测试连接成功");
        }catch (Exception e){
            e.printStackTrace();
        }finally {
            if (connection != null){
                try {
                    connection.close();
                } catch (SQLException e) {
                    e.printStackTrace();
                }
            }
        }
        return Maps.immutableEntry("0","测试连接失败");
    }
}
